Component({
  options: {
    addGlobalClass: true
  },
  properties: {
    title: {
      type: String,
      value: ''
    },
    subtitle: {
      type: String,
      value: ''
    },
    icon: {
      type: String,
      value: '/assets/icons/default.png'
    },
    target: {
      type: String,
      value: ''
    }
  },
  data: {
    iconPath: '/assets/icons/default.png'
  },
  observers: {
    icon(val) {
      this.setData({
        iconPath: val || '/assets/icons/default.png'
      });
    }
  },
  methods: {
    handleTap() {
      const url = this.data.target;
      if (url) {
        wx.navigateTo({ url });
        return;
      }
      this.triggerEvent('tap');
    }
  }
});
